<?php
//App :: import ( 'Vendor' , 'tcpdf/tcpdf' );
include(CAKE.'Clases/tcpdf/tcpdf.php');

class XTCPDF extends TCPDF
{

var $xheadertext = 'PDF created using CakePHP and TCPDF' ;
var $xheadercolor = null;//;array( 0 , 0 , 200 );
var $xfootertext = 'Copyright © %d XXXXXXXXXXX. All rights reserved.' ;
var $xfooterfont = '';//PDF_FONT_NAME_MAIN;
var $xfooterfontsize = 7 ;
var $impresopor = 'Usuario: NO DEFINIDO';
var $copy = 'Copyright © %d . Todos los derechos reservados.';
var $sistema ='';
var $tipo ='ESTANDAR';
var $margen = array(10,30, 10);
var $posy =10;
var $posx =10;
/**
* Overwrites the default header
* set the text in the view using
* $fpdf->xheadertext = 'YOUR ORGANIZATION';
* set the fill color in the view using
* $fpdf->xheadercolor = array(0,0,100); (r, g, b)
* set the font in the view using
* $fpdf->setHeaderFont(array('YourFont','',fontsize));
*/

function setTipo($t='ESTANDAR',$px=10,$py=10) {
    $this->tipo=$t;
		$this->posx=$px;
		$this->posy=$py;
}

function setMargen($margen=array()) {
    $this->margen = $margen;
}
function Header ()
{
		if($this->CurOrientation=='P') $this->Image(K_PATH_IMAGES.'agropatria.png',155,5,'41','17');
		else $this->Image(K_PATH_IMAGES.'agropatria.png',220,5,'41','17');
		$this->Image(K_PATH_IMAGES.'gobierno.jpeg',10,6,'30','17');
		list($I,$S,$D)=$this->margen;
		$this->SetMargins($I,$S,$D,true);
		if($this->tipo=='ESTANDAR'){
				$this -> setY ( 10 ); 
		} else{				
				$this->writeHTMLCell('', '', $this->posx, $this->posy, $this->tipo, 0, 0, 0, true, 'C');
		}
		
}

/**
* Overwrites the default footer
* set the text in the view using
* $fpdf->xfootertext = 'Copyright Â© %d YOUR ORGANIZATION. All rights reserved.';
*/
	function Footer ()
	{
			$year = date ( 'Y' );
			$footertext = sprintf ( $this -> xfootertext , $year );
			$this -> SetY (- 15 );
			$this -> SetTextColor ( 0 , 0 , 0 );
			$this -> SetFont ( $this -> xfooterfont , '' , $this -> xfooterfontsize );
			$this -> Cell ( 0 , 0 , $footertext , 'T' , 1 , 'L' );
			$impresopor = $this -> impresopor;
			$this -> Cell ( 0 , 0 , $impresopor , '' , 1 , 'R' );

			$sist = $this -> sistema." ".sprintf ( $this -> copy , $year );
			$this -> SetFont ( $this -> xfooterfont , '' , 5 );
			$this -> Cell ( 0 , 2 , $sist, '' , 1 , 'L' );
			$fechad = date('d-m-Y h:i:s a');
			$this -> SetFont ( $this -> xfooterfont , '' , 9 );
			$this->writeHTMLCell('', '', '8', '270', $fechad, 0, 0, 0, true, 'C');

	}
}
?>
